#include<bits/stdc++.h>
using namespace std;
const int N = 8e3 + 10;
long long a[N], qz[N];
map < long long , int > pd;
int psort(int l, int r, int x){
	int ans;
	for(int i = l; i <= r; i ++)
	    for(int j = i; j >= 2; j --){
	    	if(a[j] < a[j - 1]){
	    		swap(a[j - 1], a[j]);
	    		swap(pd[a[j - 1]], pd[a[j]]);
	    		
			} 
		}
	return ans;
}
int main(){
	freopen("sort.in", "r", stdin);
	freopen("sort.out", "w", stdout);
	int n, q;
	cin >> n >> q;
	for(int i = 1; i <= n; i ++){
		cin >> a[i];
		qz[i] = a[i];
		pd[a[i]] = i;
	}
	for(int i = 1; i <= q; i ++){
		int k;
		cin >> k;
		if(k == 1){
			int x;
			long long v;
			cin >> x >> v;
			a[x] = qz[x] = v;
		}
		else {
			int x;
			cin >> x;
			cout << psort(1, n, x) << endl;
		}
	}
	return 0;
}

